package com.smz.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.smz.entity.TProduct;
import com.smz.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class ProductController {

    @Autowired
    ProductService productService;
    @GetMapping("/products/{current}/{size}/{companyId}")
    public ResponseEntity<IPage<TProduct>> findProductByCompanyId(@PathVariable("current")int current, @PathVariable("size")int size, @PathVariable("companyId")int companyId){
        return ResponseEntity.ok(productService.findProductByCompanyId(current,size,companyId));
    }
    //根据商品id查询商品想详情
    @GetMapping("/product/{productId}")
    public ResponseEntity<TProduct> findProductById(@PathVariable("productId")int productId){
        return ResponseEntity.ok(productService.findProById(productId));
    }
    @GetMapping("/products/{current}/{size}")
    public ResponseEntity<IPage<TProduct>> findAll(@PathVariable("current")int current, @PathVariable("size")int size){
        return ResponseEntity.ok(productService.findAllPro(current,size));
    }
}
